// 函数组件快捷创建方式  Rfc

import Pts from 'prop-types'

const Sonfun = (props) => {
    console.log('props', props);
    const { count, cattoonArr } = props
    return (
        <div>
            <p>我是函数子组件-{count}</p>
            <ul>
                {
                    cattoonArr.map((item, index) => {
                        return <li key={item.id}>{item.name}</li>
                    })
                }
            </ul>
        </div>
    );
};

// 通过静态属性设置 参数类型校验和默认值
// 定义参数的类型校验
Sonfun.propTypes = {
    count: Pts.number.isRequired,
    cattoonArr: Pts.array
}

// 定义参数的默认值
Sonfun.defaultProps = {
    cattoonArr: [{
        id: 1,
        name: '熊大'
    }, {
        id: 2,
        name: '熊二'
    }]
}

export default Sonfun;
